package cn.yjr.vector.tools;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author vector
 *
 */
public class TransactionRecord {

	Date date;
	String name;
	double cost;
	public static Map<String, Double> totalCostList = new HashMap<String, Double>();
	@SuppressWarnings("deprecation")
	public TransactionRecord(Date date, String name, double cost) {
		this.date = date;
		this.name = name;
		this.cost = cost;
		int index = (date.getYear()+1900)*100 + date.getMonth()+1;
		if(totalCostList.containsKey(index+"")){
			double preCost = totalCostList.get(""+index);
			totalCostList.put(""+index, preCost + cost);
		}else{
			totalCostList.put(""+index, cost);
		}
	}
	
	@SuppressWarnings("deprecation")
	public String getYearMonth(){
		int year = date.getYear() + 1900;
		int month = date.getMonth() + 1;
		return year + "年" + month + "月";
	}
	
	public String getMonthDay(){
		int month = date.getMonth() + 1;
		int day = date.getDay();
		return month + "月" + day + "日";
	}

	public double getCost(){
		return cost;
	}
	
	public String getName(){
		return name;
	}
	
	public long getId(){
		int year = date.getYear() + 1900;
		int month = date.getMonth() + 1;
		return year*100 + month;
	}
}
